import pytest
import os
import requests
import json


@pytest.fixture(scope='function')
def api_login():  # 确保名称是 api_login（小写）
    url = os.getenv('url') + os.getenv('login')
    body = {
        'email': '1478997572@qq.com',
        'pwd': 'eWLPHopE945d2ivttHaQTQ=='
    }
    response = requests.post(url, data=body)
    print(json.dumps(response.json(), indent=2, ensure_ascii=False))
    assert "登陆成功" in response.json()['message']
    return response
